package com.qch.demo;

import java.util.concurrent.BlockingQueue;

/**
 * @Author qch
 * @Date 2021/5/11
 */
public class Consumer implements Runnable{
    private BlockingQueue<Kouzhao> queue;

    public Consumer(BlockingQueue<Kouzhao> queue) {
        this.queue = queue;
    }

    public void run() {
        //消费内容
        while (true)
        {
            try {
                Thread.sleep(100);
                System.out.println("正在准备买口罩");
                 Kouzhao take = queue.take();
                System.out.println("买到了口罩"+take.getId()+" "+take.getType());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }
}
